cd ${work}5_reg_analysis

local ylist		"exp_status log_vrd_exp_exsmall"
local felist	`" "IDY FD" "IDY FD FY" "'
local wlist		`" "c.sales##c.sales##c.sales##c.sales" "" "'

use temp\regsample_idt, clear

gen x_ols = treated_2
lab var x_ols "OLS"
gen x_iv = treated_2
lab var x_iv "2SLS"

eststo clear
local mtitles
local n=1

foreach y of local ylist {
local nfe=1	
foreach fe of local felist {
	
	local w : word `nfe' of `wlist'
	
	eststo est1: reghdfe `y' x_ols `w', a(`fe') vce(cl F) nosamp
	
	eststo est2: ivreghdfe `y' (x_iv=tdcinitiative_2) `w', a(`fe') cl(F)
	local N = e(N)
	local F = e(widstat)
	
	eststo stacked_`n' : appendmodels est1 est2
	eststo drop est*
	qui estadd scalar N `N'
	qui estadd scalar F `F'
	qui estadd local FE `fe'
	if "`w'"!=""	qui estadd local SC "Yes"
	if "`w'"==""	qui estadd local SC "No"
	local mtitles `mtitles' "`:var lab `y''"
		
	local ++n
	local ++nfe
	
}	
}
	
esttab using output\table_3.tex , replace booktabs se label ///
	title("Effect of Export Support on Trade") star(* 0.1 ** 0.05 *** 0.01) mtitles(`mtitles') keep(x_*) ///
	stats(N F FE SC , labels("Observations" "IV F-stat" "Fixed Effects" "Size Control") fmt(%10.0fc %10.0fc "" ""))